<?php
namespace App\Modules\Admin\Services;

use App\Models\Admin\Debug;
use Illuminate\Support\Str;

class DebugService extends AdminService
{
    protected $model = Debug::class;

    public function getQueryBuilder(Array $data)
    {
        $this->queryBuilder = Debug::query();
        if(isset($data['name']) && strlen($data['name']) > 0) {
            $this->queryBuilder->where('name', $data['name']);
        }

        if(isset($data['sort_by']) && isset($data['order']) && in_array(Str::lower($data['order']), ['asc', 'desc'])) {
            $this->queryBuilder->orderBy($data['sort_by'], $data['order']);
        } else {
            $this->queryBuilder->orderBy('id', 'desc');
        }
    }
}